package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.framework.web.service.SysLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Zhihj
 * @Date: 2023-04-03 21:12:57
 */

/**
 *登录验证
 */
@RestController
public class SysLoginController {

    @Autowired
    private SysLoginService sysLoginService;

    /**
     *登录方法
     * @param LoginBody
     * @return
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody LoginBody){

        AjaxResult ajaxResult = AjaxResult.success();

        //  生成令牌返回给前端
        String token = sysLoginService.login(LoginBody);

        ajaxResult.put("token",token);
        return ajaxResult;
    }
}
